/**
 * Created by Administrator on 2016/2/29.
 */

gpNamespace.BxLayer = cc.Layer.extend({
	MoneyBg: null,
	dzNum: null,
	hidBtSelect:null,
	isHid:false,//当前包厢是否隐藏
	
    ctor: function () {
        this._super();
        this.init();
    },
    init: function () {
    	cc.spriteFrameCache.addSpriteFrames(gpNamespace.pdkjdcbxRes.PdkJdcBx_plist);
        //底注背景
        var dzBg=new cc.Sprite(gpNamespace.bx.Bx_Dz_Bg);
        dzBg.attr({
            x: 95+dzBg.width/2,
            y: 450+dzBg.height/2,
        });
        this.addChild(dzBg);
        //隐藏按钮
        var hidBt = new cc.MenuItemImage(gpNamespace.bx.Bx_HidBt, gpNamespace.bx.Bx_HidBt, this.hidCallbackFunction, this);

        var hidBtMenu = new cc.Menu(hidBt);
        hidBtMenu.attr({
            x: 300+hidBt.width/2,
            y: dzBg.getPositionY()+5,
        });
        hidBtMenu.alignItemsHorizontally();
        this.addChild(hidBtMenu);
        
        //隐藏按钮勾选
        var hidBtSelect = new cc.Sprite(gpNamespace.bx.Bx_HidSelect);
        hidBtSelect.attr({
        	x:15,
        	y:15
        });
        hidBtSelect.visible = false;
        this.hidBtSelect = hidBtSelect;
        hidBt.addChild(hidBtSelect);

        //金额背景
        var MoneyBg=new cc.Sprite(gpNamespace.bx.Bx_MoneyBg);
        MoneyBg.attr({
//            x: 443+MoneyBg.width/2,
            x: 485,
            y: dzBg.getPositionY()+3,
        });
//        console.log("X:"+443+MoneyBg.width/2);
        this.MoneyBg = MoneyBg;
        this.addChild(MoneyBg);



        //底注
        var dz5000M = new cc.MenuItemImage(gpNamespace.bx.Bx_5000M, gpNamespace.bx.Bx_5000M, this.dz5000MCallbackFunction, this);
        var dz10000M = new cc.MenuItemImage(gpNamespace.bx.Bx_10000M, gpNamespace.bx.Bx_10000M, this.dz10000MCallbackFunction, this);
        var dz20000M = new cc.MenuItemImage(gpNamespace.bx.Bx_20000M, gpNamespace.bx.Bx_20000M, this.dz20000MCallbackFunction, this);
        var dz50000M = new cc.MenuItemImage(gpNamespace.bx.Bx_50000M, gpNamespace.bx.Bx_50000M, this.dz50000MCallbackFunction, this);

        var dzMenu = new cc.Menu(dz5000M, dz10000M, dz20000M,dz50000M);

        dzMenu.attr({
            x: 620,
            y: dzBg.getPositionY()+5,
        });
        dzMenu.alignItemsHorizontallyWithPadding(50);
        this.addChild(dzMenu);


        //刷新
        var reFresh = new cc.MenuItemImage(gpNamespace.bx.Bx_RefreshBt, gpNamespace.bx.Bx_RefreshBt, this.settingCallbackFunction, this);

        var reFreshMenu = new cc.Menu(reFresh);
        reFreshMenu.attr({
            x: 838+reFresh.width/2,
            y: dzBg.getPositionY(),
        });
        reFreshMenu.alignItemsHorizontally();
        this.addChild(reFreshMenu);

        //创建房间
        var createRoom = new cc.MenuItemImage(gpNamespace.bx.Bx_CreateRoomBt, gpNamespace.bx.Bx_CreateRoomBt, this.showCreateFunction, this);

        var createRoomMenu = new cc.Menu(createRoom);
        createRoomMenu.attr({
            x: 1006+createRoom.width/2,
            y: dzBg.getPositionY(),
        });
        createRoomMenu.alignItemsHorizontally();
        this.addChild(createRoomMenu);



        //包厢列表背景
        var bxListBg=new cc.Sprite(gpNamespace.bx.Bx_ListBg);
        bxListBg.attr({
            x: 75+bxListBg.width/2,
            y: 70+bxListBg.height/2,
        });
        this.addChild(bxListBg);
    },
    hidCallbackFunction:function(){
    	console.log("隐藏按钮");
    	if(this.isHid){
    		this.hidBtSelect.visible = false;
    		this.isHid = false;
    	}else{
    		this.hidBtSelect.visible = true;
    		this.isHid = true;
    	}
    },
    dz5000MCallbackFunction:function(){
    	this.MoneyBg.x = 485;
    },
    dz10000MCallbackFunction:function(){
    	this.MoneyBg.x = 485 + 90;
    },
    dz20000MCallbackFunction:function(){
    	this.MoneyBg.x = 485 + 90*2;
    },
    dz50000MCallbackFunction:function(){
    	this.MoneyBg.x = 485 + 90*3;
    },
    showCreateFunction:function(sender) {
//        cc.log("创建房间显示");
        tyNamespace.setMenuEnable(sender);
        tyNamespace.tipsJumper(1,tyNamespace.TipsSectencesIndex.PleaseWaiting); // 敬请期待
    }
});